var status = -1;
var selectionLog = [];

function action(h, f, e) {
    if (status == 0 && h == 0) {
        cm.dispose();
        return
    }
    status++;
    selectionLog[status] = e;
    var c = -1;
    if (status <= c++) {
        cm.dispose()
    } else {
        if (status === c++) {
            cm.setStringForQuestInfo(3847, "Result", "complete");
            var b = cm.getNumberFromQuestInfo(3847, "Floor");
            var d = cm.getNumberFromQuestInfo(3847, "Time");
            var g = "辛苦啦。再接再厉继续挑战。\r\n\r\n<最近记录信息>\r\n#b  - 排名区间：精通\r\n  - 通关层数：" + b + "层\r\n  - 花费时间：" + d + "秒#k\r\n\r\n";
            cm.setNumberForQuestInfo(100466, "Time", cm.getNumberFromQuestInfo(3847, "Time"));
            cm.setNumberForQuestInfo(100466, "Scr", 1);
            var a = cm.getNumberFromQuestInfo(100466, "Floor");
            if (b > a) {
                cm.getTopMsgFont("- 达成最高纪录 -", 3, 25, 4, 0);
                if (a % 100 < 15 && b % 100 >= 15) {
                    g += "这次你突破了第十五层！这是你的额外奖励：\r\n#i3700305##b#t3700305#\t#i1082710##b#t1082710#\r\n\r\n#k";
                    cm.gainItem(3700305, 1);
                    cm.gainItem(1082710, 1)
                }
                if (a % 100 < 30 && b % 100 >= 30) {
                    g += "这次你突破了第三十层！这是你的额外奖励：\r\n#i3700306##b#t3700306#\t#i1082394##b#t1082394#\r\n\r\n#k";
                    cm.gainItem(3700306, 1);
                    cm.gainItem(1082394, 1)
                }
                if (a % 100 < 45 && b % 100 >= 45) {
                    g += "这次你突破了第四十五层！这是你的额外奖励：\r\n#i3700307##b#t3700307#\t#i1082393##b#t1082393#\r\n\r\n#k";
                    cm.gainItem(3700307, 1);
                    cm.gainItem(1082393, 1)
                }
                if (a % 100 < 63 && b % 100 >= 63) {
                    g += "这次你突破了武陵道场的所有关卡！真是太了不起了！这是你的额外奖励：\r\n#i3700308##b#t3700308#\t#i1082392##b#t1082392#\r\n\r\n#k";
                    cm.gainItem(3700308, 1);
                    cm.gainItem(1082392, 1)
                }
                cm.setNumberForQuestInfo(100466, "Floor", b)
            }
            if (cm.getMapId() == 925020003) {
                cm.getPlayer().dropMessage(-1, "恭喜，你已经通关了武陵道场的所有关卡.")
            }
            cm.sendNormalTalk(g, 5, 2091011, false, false);
            cm.dojoAgent_UpdateRecord();
            cm.dispose()
        } else {
            cm.dispose()
        }
    }
}

function start() {
    status = -1;
    action(1, 0, 0)
};